% % picking prototype
% fileName = 'MVI_0096.avi';
% hvideo = implay(fileName);
% % close(hvideo)

% crop the head from image
imgList = dir(fullfile('prototype','frame*.jpg'));
desDir = 'prototypeHead';
nImg = numel(imgList);

for ii = 1:nImg
    imgFileName = fullfile('prototype',imgList(ii).name);
    tmpImg = imread(imgFileName);
    imshow(tmpImg);
    rectSize = [190,32,239,239];
    rectangle('position',rectSize);
    cropImg = imcrop(tmpImg,rectSize);
    if ~exist(desDir,'dir')
        mkdir(desDir)
    end
    imwrite(cropImg,fullfile(desDir,sprintf('himg%d.jpg',ii)));
    pause;
end

%%
% hand pick the image for some state

%%
imgList = dir(fullfile('orderedHead','*.jpg'));
imageNames = SortName(imgList);
dataBase = struct('image',[],'HoG',[],'label',[]);
for ii = 1:numel(imgList)
    dataBase(ii).image = imread(fullfile('orderedHead',imageNames{ii}));
    dataBase(ii).HoG =  HoG(im2double(dataBase(ii).image));
    dataBase(ii).label = regexp([imageNames{ii}],'(\d*)','match');
end
save('dataBase','dataBase');